package com.example.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplusdemo.model.domain.MerchantPost;
import com.example.mybatisplusdemo.mapper.MerchantPostMapper;
import com.example.mybatisplusdemo.model.dto.PageDTO;
import com.example.mybatisplusdemo.model.dto.PostDTO;
import com.example.mybatisplusdemo.model.vo.MerchantPostVO;
import com.example.mybatisplusdemo.service.IMerchantPostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2025-07-04
 */
@Service
public class MerchantPostServiceImpl extends ServiceImpl<MerchantPostMapper, MerchantPost> implements IMerchantPostService {

    @Autowired
    private MerchantPostMapper merchantPostMapper;

    @Override
    public List<PostDTO> listPublicPost(Page<PostDTO> page) {
        return merchantPostMapper.listPublicPost(page);
    }

    @Override
    public List<PostDTO> listFavoritePostByUserId(Page<PostDTO> page, Long userId) {
        return merchantPostMapper.listFavoritePostByUserId(page, userId);
    }

    @Override
    public Page<MerchantPostVO> listPagingPostsByStoreIdWithStoreName(PageDTO pageDTO, Long storeId) {
        Page<MerchantPostVO> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        page = merchantPostMapper.listPagingPostsByStoreIdWithStoreName(page, storeId);
        return page;
    }
}
